package com.wj.im.common;

import org.junit.After;
import org.junit.Before;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter;

/**
 *
 * @author Smile.Wu
 * @version 2015-11-11
 */
public class JunitConsole {
	private long beginTime = 0;
	@Before
	public void initJunitConsole() {
		beginTime = System.currentTimeMillis();
	}
	
	@After
	public void endJunitConsole() {
		long delt = System.currentTimeMillis() - beginTime;
		console("cost : " + delt);
	}
	public void println(Object ...s){
		StringBuilder sb = new StringBuilder("");
		for(Object t : s) {
			sb.append(t).append(" ");
		}
		System.out.println(sb);
	}

	public static void console(Object obj) {
		System.out.println("[jUnit] " + obj);
	}
	public static void console() {
		console("");
	}
	public static void console(String line, Object...objects) {
		FormattingTuple ft = MessageFormatter.arrayFormat(line, objects);
		console(ft.getMessage());
	}
	
	public static String join(String line, Object...objects) {
		FormattingTuple ft = MessageFormatter.arrayFormat(line, objects);
		return ft.getMessage();
	}
}
